package com.kang.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kang.bean.FriendGroup;
import com.kang.bean.Users;
import com.kang.mapper.FriendGroupMapper;
import com.kang.service.FriendGroupService;
import com.kang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: photo_fawu
 * @description:
 * @author: K.faWu
 * @create: 2021-11-09 10:51
 **/
@Service
public class FriendGroupServiceImpl extends ServiceImpl<FriendGroupMapper, FriendGroup> implements FriendGroupService {

    @Autowired
    private FriendGroupMapper friendGroupMapper;
    @Autowired
    private UserService userService;

    @Override
    public void addFriendGroup(FriendGroup friendGroup, HttpServletRequest request) {
        if (friendGroup.getUserId() == null) {
            Users users = userService.getUsers(request.getHeader("token"));
            friendGroup.setUserId(users.getId());
        }
        friendGroupMapper.insert(friendGroup);
    }
}
